# Windows 防火墙配置脚本
# 需要以管理员身份运行

# 1. 允许 ICMP Echo Request (ping)
netsh advfirewall firewall add rule name="Allow ICMP Echo Request" dir=in action=allow protocol=icmpv4

# 2. 允许 Nacos 端口
netsh advfirewall firewall add rule name="Nacos Server" dir=in action=allow protocol=TCP localport=8848

# 3. 允许 Gateway 端口
netsh advfirewall firewall add rule name="PmHub Gateway" dir=in action=allow protocol=TCP localport=6880

# 4. 允许 SSH 端口 (如果使用 Remote-SSH)
netsh advfirewall firewall add rule name="OpenSSH Server" dir=in action=allow protocol=TCP localport=22

# 5. 允许 Auth 服务端口
netsh advfirewall firewall add rule name="PmHub Auth" dir=in action=allow protocol=TCP localport=6800

# 6. 允许 System 服务端口
netsh advfirewall firewall add rule name="PmHub System" dir=in action=allow protocol=TCP localport=6801

# 7. 允许 Project 服务端口
netsh advfirewall firewall add rule name="PmHub Project" dir=in action=allow protocol=TCP localport=6806

# 8. 允许 Workflow 服务端口
netsh advfirewall firewall add rule name="PmHub Workflow" dir=in action=allow protocol=TCP localport=6808

# 9. 允许 Monitor 服务端口
netsh advfirewall firewall add rule name="PmHub Monitor" dir=in action=allow protocol=TCP localport=6888

Write-Host "防火墙配置完成！" -ForegroundColor Green
Write-Host "现在可以从 Mac (192.168.0.5) ping 通本机了" -ForegroundColor Cyan